package cn.yunyichina.openapi.proxy.dubbo.core.context;

import cn.yunyichina.utils.commons.StringUtils;
import org.slf4j.MDC;

/**
 * Created by kevin on 2017/11/30.
 */
public class TraceContext extends AbstractContext {

    public static final String TRACE_ID_KEY = "traceId";

    public static void setTraceId(String traceId) {
        MDC.put(TRACE_ID_KEY,traceId);
    }

    public static String getTraceId() {
        return MDC.get(TRACE_ID_KEY);
    }

    public static void clear() {
        MDC.remove(TRACE_ID_KEY);
    }

    public static boolean containsTraceId(){
       if(StringUtils.isBlank(getTraceId())){
           return false;
       }
       return true;
    }
}
